//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#if _MSC_VER > 1000
#pragma once
#endif

#ifndef __OSTIMER_H__
#define __OSTIMER_H__

#ifdef  __cplusplus
extern "C" {
#endif

/* set timer flag to configure the OMCRx register. */
/* the asterisk masked macro should be set!!!!!!!!!!!!!!!!!!!!!!! */
//set Counter Resolution                                                (*)
#define OST_COUNTER_DISABLE         0x0000      //The counter is disabled.

#define OST_1_32768OFSECOND_COUNTER 0x0001      //1/32768th of a second.
#define OST_1MILLISECOND_COUNTER    0x0002      //1 millisecond.The interval between clock increments averages
                                                //one millisecond, but the time between individual clock increments
                                                //varies because the counter resolution is derived from the 32.768-
                                                //kHz clock.
#define OST_1SECOND_COUNTER         0x0003      //1 second.
#define OST_1MICROSECOND_COUNTER    0x0004      //1 microsecond.

//set Reset OSCRx on Match                                              (*)
#define OST_RESET_ENABLE      0x0008            //Reset OSCRx on match. otherwise do not reset on match.

//set Periodic Timer                                                    (*)
#define OST_PERIODIC_ENABLE         0x0040      //The channel continues incrementing after detecting a match.

//set Timer interrupt Enable                                            (*)
#define OST_INT_ENABLE              0x1000      //set interrupt mode, hook a interrupt service routine.
                                                //otherwise poll mode. get ostimer counter directly.

typedef Boolean (*OST_ISRFUNC)(void* pDevice, PBoolean pWakeup);

#define TIMER_NUM 30

typedef struct {
    PVoid  timerChannel;       //timer channel number
    int     timerInterval;      //timer interval value, used for call OSTStart func.
    UInt32    timerFlags;         //timer flag, used for call OSTStart func.
    void   *timerDevice;        //used in future
    OST_ISRFUNC timerIsrFunc;   //used in future
}OST_TIMER_PARAM_DESC;

/* OS Timer exported API*/
//PVoid OSTCreate(PTR Device, OST_ISRFUNC TimerIsrFunc);
//Boolean OSTKill(PVoid tHandle);
//Boolean OSTStart(PVoid tHandle, int Interval/*Milli Seconds*/, UInt32 Flags);
//Boolean OSTStop(PVoid tHandle);
//Boolean OSTPause(PVoid tHandle);
//Boolean OSTSetInterval(PVoid tHandle, int Interval);
//UInt32 OSTGetTicks(PVoid tHandle);

#ifdef  __cplusplus
}
#endif

#endif//__TIMER_H__
